<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>递归</title>
</head>
<body>
  <script>
    // 命名函数表达式
    const factorial = function f(num) {
      if (num <= 1) {
        return 1;
      } else {
        return num * f(num - 1);
      }
    };
    const factorialResult = factorial(4);
    console.log(factorialResult);  // 24
  </script>
</body>
</html>